<?
class mdl_mp extends CI_Model{
	
	function __construct(){
		parent::__construct();
	}
	
	function getData($num=0, $offset=0){
		$this->db->flush_cache();
		$thn=$this->session->userdata("thnanggaran");
		$this->db->select('*', false);
		$this->db->from('mp_tbl_mp');
		$array = array('TahunAnggaran' => $thn);
		$this->db->where($array); 
		$this->db->limit($num, $offset);
		$this->db->order_by('TahunAnggaran');
		$this->db->order_by('Prioritas');
		
		return $this->db->get();
		
	}
	
	function getDataEdit($id){
		$this->db->flush_cache();
		$this->db->select('*');
		$this->db->from('mp_tbl_mp');
		$this->db->where('id', $id);
		
		return $this->db->get();
	}
	function ambilbaris()
	{	$thn=$this->session->userdata("thnanggaran");
		$query="Select TahunAnggaran from m_mp where TahunAnggaran = $thn";
		return  $this->db->count_all_results($query);
	}
	
	function prioritas()
	{
	$prioritas=$this->input->$_POST['prioritas'];
	$array = array('prioritas' => $prioritas);
	$this->db->set($array);
	$this->db->insert('m_tbl_mp'); 
	}

	function insert($data){
		$this->db->flush_cache();
        //$this->db->set('IDDOSEN', $data['IDDOSEN']);
        $this->db->set('NIP', $data['NIP']);
        $this->db->set('NAMADOSEN', $data['NAMADOSEN']);
		$this->db->set('TEMPAT_LAHIR', $data['TEMPAT_LAHIR']);
		$this->db->set('TGL_LAHIR', $data['TGL_LAHIR'], false);
		$this->db->set('JK', $data['JK']);
		$this->db->set('STATUS', $data['STATUS']);
		$this->db->set('TAHUN', $data['TAHUN']);
		$this->db->set('PENDIDIKAN', $data['PENDIDIKAN']);
		$this->db->set('JENIS_DOSEN', $data['JENIS_DOSEN']);
		$this->db->set('KODE_UPT', $data['KODE_UPT']);

        $result = $this->db->insert('DIKLAT_MST_DOSEN');

		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
		
	}
	
	function update($data){
		$this->db->flush_cache();
        
        /*$this->db->set('TglCreate', $data['TglCreate']);
        $this->db->set('kd_akun', $data['kd_akun']);
		$this->db->set('kd_wilayah', $data['kd_wilayah']);
		$this->db->set('uraian', $data['uraian']);
		$this->db->set('detailLokasi', $data['detailLokasi']);
		*/
		$this->db->set('Prioritas', $data['Prioritas']);
		
		$this->db->where('id', $data['id']);
		
		$result = $this->db->update('mp_tbl_mp');
		
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
		
	}
	
	/*function delete($id){
		$this->db->flush_cache();
		$this->db->where('IDDOSEN', $id);
		$result = $this->db->delete('DIKLAT_MST_DOSEN');
		
		if($result) {
			return TRUE;
		}else {
			return FALSE;
		}
		
	}*/
	
	
}
?>